package com.ayu.shortlink.engine.mq.consumer;

import com.ayu.shortlink.engine.common.constant.RocketMQConstant;
import com.ayu.shortlink.engine.mq.basics.base.MessageWrapper;
import com.ayu.shortlink.engine.mq.basics.event.CouponRemindEvent;
import com.ayu.shortlink.engine.service.handler.remind.ExecuteCouponRemindHandler;
import lombok.RequiredArgsConstructor;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 用户预约提示消费者V2
 */
@Component
@RequiredArgsConstructor
@RocketMQMessageListener(
        topic = RocketMQConstant.TOPIC_COUPON_REMIND_ON_TIME_V2,
        consumerGroup = RocketMQConstant.GROUP_COUPON_REMIND_ON_TIME_V2
)
public class CouponRemindConsumer2 implements RocketMQListener<MessageWrapper<CouponRemindEvent>> {
    private final ExecuteCouponRemindHandler executeCouponRemindHandler;

    @Override
    public void onMessage(MessageWrapper<CouponRemindEvent> messageWrapper) {
        CouponRemindEvent message = messageWrapper.getMessage();

        // 进行用户预约提醒
        executeCouponRemindHandler.handler(message);
    }
}
